From 48bfc9badf066f810b80bf3158ed13ad80275fbb Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Mon, 1 Jan 2018 17:56:35 -0500 Subject: [PATCH] testinput: Make this work again This test was not updated to using a draw func instead of the ::draw signal yet. At the same time, make it use ::size-allocate instead of ::configure-event. --- tests/testinput.c | 55 ++++++++++++++++++++++++++--------------------- 1 file changed, 30 insertions(+), 25 deletions(-) diff --git a/tests/testinput.c b/tests/testinput.c index 20358f893f..5143b110b2 100644 --- a/tests/testinput.c +++ b/tests/testinput.c @@ -32,39 +32,46 @@ static cairo_surface_t *surface = NULL; /* Create a new backing surface of the appropriate size */ -static gint -configure_event (GtkWidget *widget, GdkEventConfigure *event) +static void +size_allocate (GtkWidget *widget, + GtkAllocation *allocation, + int baseline, + GdkRectangle *clip, + gpointer data) { - GtkAllocation allocation; - cairo_t *cr; - if (surface) - cairo_surface_destroy (surface); - - gtk_widget_get_allocation (widget, &allocation); + { + cairo_surface_destroy (surface); + surface = NULL; + } - surface = gdk_window_create_similar_surface (gtk_widget_get_window (widget), - CAIRO_CONTENT_COLOR, - allocation.width, - allocation.height); - cr = cairo_create (surface); + if (gtk_widget_get_window (widget)) + { + cairo_t *cr; - cairo_set_source_rgb (cr, 1, 1, 1); - cairo_paint (cr); + surface = gdk_window_create_similar_surface (gtk_widget_get_window (widget), + CAIRO_CONTENT_COLOR, + gtk_widget_get_width (widget), + gtk_widget_get_height (widget)); + cr = cairo_create (surface); - cairo_destroy (cr); + cairo_set_source_rgb (cr, 1, 1, 1); + cairo_paint (cr); - return TRUE; + cairo_destroy (cr); + } } /* Refill the screen from the backing surface */ -static gboolean -draw (GtkWidget *widget, cairo_t *cr) +static void +draw (GtkDrawingArea *drawing_area, + cairo_t *cr, + int width, + int height, + gpointer data) { cairo_set_source_surface (cr, surface, 0, 0); cairo_paint (cr); - - return FALSE; } /* Draw a rectangle on the screen, size depending on pressure, @@ -280,10 +287,8 @@ main (int argc, char *argv[]) /* Signals used to handle backing surface */ - g_signal_connect (drawing_area, "draw", - G_CALLBACK (draw), NULL); - g_signal_connect (drawing_area, "configure_event", - G_CALLBACK (configure_event), NULL); + gtk_drawing_area_set_draw_func (GTK_DRAWING_AREA (drawing_area), draw, NULL, NULL); + g_signal_connect (drawing_area, "size-allocate", G_CALLBACK (size_allocate), NULL); /* Event signals */ -- 2.30.2